import { createSSRApp } from "vue";
import App from "./App.vue";

import ElementPlus from "element-plus";
import "element-plus/dist/index.css";
import "./assets/style/index.scss";
import * as ElementPlusIconsVue from "@element-plus/icons-vue";
import { createRouter } from "./router";

export const createApp = () => {
  const app = createSSRApp(App);

  app.config.globalProperties.$isMobile = import.meta.env.SSR
    ? false
    : /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(
        navigator.userAgent
      );
      
  app.config.globalProperties.a = import.meta.env.SSR ? true : false;

  for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
    app.component(key, component);
  }

  const router = createRouter();
  app.use(ElementPlus);
  app.use(router);

  return { app, router };
};
